package com.xixibaby.message.channel.dingding;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class DDMessage {

    private String msgtype = "text";
    private Text text;
    private Markdown markdown;
    private String context;

    private At at;

    public DDMessage(String context){
        Text text = new Text();
        text.setContent(context);
        this.text = text;
    }

    public DDMessage(){

    }

    public void setContext(String context) {
        if("markdown".equals(this.msgtype)){
            if(null != this.markdown){
                this.markdown.setText(context);
            }else{
                this.markdown = new Markdown();
                markdown.setText(context);
            }
        }else{
            Text text = new Text();
            text.setContent(context);
            this.text = text;
        }
    }

    @Getter
    @Setter
    public static class At{
        private String[] atMobiles;
        private  boolean isAtAll = false;
    }

    @Getter
    @Setter
    public static class Text{
        private String content;
    }

    @Getter
    @Setter
    public static class Markdown{
        private String title;
        private String text;
    }


}
